<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="./templates/rpsTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <p:growl id="growl" showDetail="true" globalOnly="true"/>
        <h:form id="frm-applicant">
            <div class="content-box">
                <div class="content-box-header">
                    <h3>List Applicants</h3>
                </div><!-- End .content-box-header -->

                <div class="content-box-content">
                    <div class="tab-content default-tab">
                        <div id="search-vacancy">
                            <fieldset>
                                <label>Search :</label>
                                <h:inputText value="#{manageApplicantBean.keyword}"
                                             styleClass="text-input medium-input">
                                </h:inputText>

                                <label>Status :</label>
                                <h:selectOneMenu id="cboStatus"
                                                 value="#{manageApplicantBean.status}"
                                                 styleClass="text-input small-input">
                                    <f:selectItem itemLabel="All applicants"  itemValue="-99"/>
                                    <f:selectItem itemLabel="Not In Progress" itemValue="0"/>
                                    <f:selectItem itemLabel="In Progress" itemValue="99" />
                                    <f:selectItem itemLabel="Hired" itemValue="1" />
                                    <f:selectItem itemLabel="Banned" itemValue="-1" />
                                </h:selectOneMenu>
                                <h:commandButton value="Search"
                                                 actionListener="#{manageApplicantBean.search()}"
                                                 styleClass="schedule button">
                                </h:commandButton>
                            </fieldset>
                        </div>
                        <h:panelGroup rendered="#{manageApplicantBean.msgSearch!=''}">
                            <h3 class="msg">#{manageApplicantBean.msgSearch}</h3>
                        </h:panelGroup>
                        <h:panelGroup id="table" rendered="#{not empty manageApplicantBean.applicants}">
                            <div class="article">
                                <h:dataTable value="#{manageApplicantBean.applicants}"
                                             var="applicant"
                                             columnClasses="col-30,col-180,col-100,col-180,col-120,col-150,col-center">
                                    <h:column>
                                        <h:graphicImage value="resources/images/other/not_in_progress.png"
                                                        rendered="#{applicant.status == 0}"
                                                        title="Not in progress"/>
                                        <h:graphicImage value="resources/images/other/postpone.png"
                                                        rendered="#{applicant.status == 99}"
                                                        title="In progress"/>
                                        <h:graphicImage value="resources/images/other/select.png"
                                                        rendered="#{applicant.status == 1}"
                                                        title="Hired"/>
                                        <h:graphicImage value="resources/images/other/remove.png"
                                                        rendered="#{applicant.status == -1}"
                                                        title="Banned"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">Full Name</f:facet>
                                        #{applicant.firstName} #{applicant.lastName}
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">DOB</f:facet>
                                        #{calendarMB.dateFormat(applicant.dob)}
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">Email</f:facet>
                                        #{applicant.email}
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">Phone Number</f:facet>
                                        #{applicant.phoneNumber}
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">Address</f:facet>
                                        #{applicant.address}
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">Action</f:facet>
                                        <h:button outcome="applicant-info.xhtml"
                                                  title="Applicant information"
                                                  image="resources/images/icons/info.png">
                                            <f:param name="id" value="#{applicant.applicantID}"/>
                                        </h:button>
                                        <h:panelGroup rendered="#{accountMB.hRGroup}">
                                            <h:button outcome="applicant.xhtml"
                                                      title="Edit information"
                                                      image="resources/images/icons/edit.png">
                                                <f:param name="id" value="#{applicant.applicantID}"/>
                                            </h:button>
                                            <h:button outcome="attach.xhtml"
                                                      title="Attach vacancies"
                                                      image="resources/images/icons/attach.png"
                                                      rendered="#{applicant.status==0}">
                                                <f:param name="id" value="#{applicant.applicantID}"/>
                                            </h:button>
                                            <h:commandButton image="resources/images/icons/remove.png"
                                                             title="Banned"
                                                             onclick="return remove();"
                                                             rendered="#{applicant.status == 1}"
                                                             actionListener="#{manageApplicantBean.banned()}">
                                                <f:param name="id" value="#{applicant.applicantID}"/>
                                                <f:ajax execute="@this" render="@form :growl"/>
                                            </h:commandButton>
                                        </h:panelGroup>
                                    </h:column>
                                </h:dataTable>
                            </div>
                        </h:panelGroup>
                    </div>
                </div>
            </div>
            <script type="text/javascript">
                function remove(){
                    return confirm("The applicant will be BANNED.\n\
\n\
Are you sure to banned this applicant?");
                }

                $('.remove input').removeClass('ui-inputfield');
            </script>
        </h:form>
    </ui:define>

</ui:composition>
